# -*- encoding: utf-8 -*-
# @File    :   article.py
# @Time    :   2021/07/27 11:55:07
# @Author  :   wudongmin
# @Contact :   wudongmin@xroom.net
# @version   :  1.0

from sqlalchemy.sql.schema import ForeignKey
from app.db import article
from . import Base, TimestampMixin
from sqlalchemy import Column, Integer, String, Text
from sqlalchemy.orm import relationship


class Article(Base, TimestampMixin):
    __tablename__ = 'articles'
    id = Column(Integer, primary_key=True, autoincrement=True, comment="文章id")
    title = Column(String(255), unique=True, nullable=False, comment="文章标题")
    description = Column(String(255), nullable=True, comment="文章描述")
    cover_url = Column(String(255), nullable=False, comment="封面图")
    content = Column(Text, comment="文章内容")
    article_type_id = Column(Integer, ForeignKey("article_types.id"))
    article_type = relationship("ArticleType", backref="articles_of_article_types")


class Animation(Base):
    __tablename__ = 'animations'
    title = Column(String(255), primary_key=True, comment="番剧标题")
    cover_url = Column(String(255), nullable=False, comment="封面图")

class ArticleType(Base):
    __tablename__ = 'article_types'
    id = Column(Integer, primary_key=True, autoincrement=True, comment="文章类型id")
    title = Column(String(255), unique=True, nullable=False, comment="文章类型标题")